//
//  CustomViewController.m
//  CivilianTravel
//
//  Created by xalo on 16/7/12.
//  Copyright © 2016年 许仕杰. All rights reserved.
//

#import "CustomViewController.h"
#import "HomePageViewController.h"
#import "DestinationViewController.h"
#import "CircumViewController.h"
#import "SetViewController.h"
#import "CustomTabBar.h"
@interface CustomViewController ()

@end

@implementation CustomViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    //通过appearance统一设置所有UITabBarTtem的文字属性
    NSMutableDictionary *attrs = [NSMutableDictionary dictionary];
    attrs[NSFontAttributeName] = [UIFont systemFontOfSize:12];
    attrs[NSForegroundColorAttributeName] = [UIColor grayColor];
    
    NSMutableDictionary *selectedAttrs = [NSMutableDictionary dictionary];
    selectedAttrs[NSFontAttributeName] = attrs[NSFontAttributeName];
    selectedAttrs[NSForegroundColorAttributeName] = [UIColor darkGrayColor];
    
    UITabBarItem *item = [UITabBarItem appearance];
    [item setTitleTextAttributes:attrs forState:UIControlStateNormal];
    [item setTitleTextAttributes:selectedAttrs forState:UIControlStateSelected];
    
    //添加子控制器
    [self setupChildVC:[[UINavigationController alloc] initWithRootViewController:[[HomePageViewController alloc] init]] title:@"首页" image:@"homePage" selectedImage:@"homePageSelect"];
    [self setupChildVC:[[UINavigationController alloc] initWithRootViewController:[[DestinationViewController alloc] init]] title:@"目的地" image:@"destination" selectedImage:@"destinationSelect"];
    [self setupChildVC:[[UINavigationController alloc] initWithRootViewController:[[CircumViewController alloc] init]] title:@"周边游" image:@"circum" selectedImage:@"circumSelect"];
    [self setupChildVC:[[UINavigationController alloc] initWithRootViewController:[[SetViewController alloc] init]] title:@"设置" image:@"set" selectedImage:@"setSelect"];
    [self setValue:[[CustomTabBar alloc] init] forKey:@"tabBar"];
    
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
}


/**
 *  初始化子控制器
 */
- (void)setupChildVC:(UIViewController *)vc title:(NSString *)title image:(NSString *)image selectedImage:(NSString *)selectedIamge{
    //设置文字和图片
    vc.tabBarItem.title = title;
    vc.tabBarItem.image = [UIImage imageNamed:image];
    vc.tabBarItem.selectedImage = [UIImage imageNamed:selectedIamge];
    vc.view.backgroundColor = [UIColor colorWithRed:217/255.0 green:217/255.0 blue:217/255.0 alpha:1.0];
    //添加为子控制器
    [self addChildViewController:vc];
    
}




@end
